package com.william.jdbcplus.core.condition.segment.impl;

import com.william.jdbcplus.core.enums.SqlKeyword;
import com.william.jdbcplus.core.toolkit.StringPool;

import java.util.stream.Collectors;

/**
 * set SQL 片段
 *
 * @author niliwei
 */
public class SetSegmentList extends AbstractSegmentList {

    @Override
    public String getSegment() {
        if (isEmpty()) {
            return StringPool.EMPTY;
        }
        return this.stream().collect(Collectors.joining(StringPool.COMMA));
    }

    @Override
    public String getSql() {
        if (isEmpty()) {
            return StringPool.EMPTY;
        }

        return StringPool.SPACE + SqlKeyword.SET.toString() + StringPool.SPACE + getSegment();
    }
}